package com.jsu.information.controller.v1;


import com.jsu.information.service.impl.AchievementServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.example.model.information.dto.AchievementDto;
import org.example.model.information.pojo.AchievementTry;
import org.example.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/information/web/v1/achievement")
@Api(tags = "成果信息控制器")
public class AchievementController {
    @Autowired
    private AchievementServiceImpl achievementService;

    @ApiOperation(value = "关键字搜索成果信息")
    @GetMapping("/search/{key}")
    public ResponseResult searchAchievement(@PathVariable("key") String key) {
        return achievementService.searchAchievement(key);
    }

    @ApiOperation(value = "批量删除成果信息")
    @DeleteMapping("/delete/batch")
    public ResponseResult deleteAchievementBatch(@RequestBody int[] ids) {
        return achievementService.deleteAchievementBatch(ids);
    }

    @ApiOperation(value = "删除成果信息")
    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteAchievement(@PathVariable("id") int id) {
        return achievementService.deleteAchievement(id);
    }

    @ApiOperation(value = "修改成果信息")
    @PostMapping("/update")
    public ResponseResult updateAchievement(@RequestBody AchievementDto achievementDto) {
        return achievementService.updateAchievement(achievementDto);
    }
    @ApiOperation(value = "添加成果信息")
    @PostMapping("/add")
    public ResponseResult addAchievement(@RequestBody AchievementDto achievementDto) {
        return achievementService.addAchievement(achievementDto);
    }

    @ApiOperation(value = "获取成果信息")
    @GetMapping("/get")
    public ResponseResult getAchievement(){
        return achievementService.getAchievement();
    }

    @ApiOperation(value = "试用成果")
    @PostMapping("/try")
    public ResponseResult tryAchievement(@RequestBody AchievementTry achievementTry){
        return achievementService.tryAchievement(achievementTry);
    }

    @ApiOperation(value = "获取需要审核的成果试用表单")
    @GetMapping("/get/form")
    public ResponseResult getForm(){
        return achievementService.getForm();
    }

    @ApiOperation(value = "获取所有成果试用列表")
    @GetMapping("/get/try/all")
    public ResponseResult getAllTryList(){
        return achievementService.getAllTryList();
    }

    @ApiOperation(value = "管理员审批试用表")
    @PostMapping("/check/one")
    public ResponseResult checkOneTry(@RequestBody AchievementTry achievementTry){
        return achievementService.checkOneTry(achievementTry);
    }

    @ApiOperation(value = "上传文件")
    @PostMapping("/upload")
    public ResponseResult uploadExcel(@RequestParam("file") MultipartFile file) {
        return achievementService.uploadExcel(file);
    }

    @ApiOperation(value = "导出文件")
    @GetMapping("/export")
    public ResponseResult exportExcel(@RequestParam("fileName") String fileName) {
        return achievementService.exportExcel(fileName);
    }

    //TODO 模糊查询

    @ApiOperation(value = "按活动id获取成果使用表列表")
    @GetMapping("/get/try/{id}")
    public ResponseResult getTryList(@PathVariable("id") int id){
        return achievementService.getTryList(id);
    }


}
